/*
 * Copyright (C) 2013 Félix Marín Ramírez | felixmurcia@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * DOCUMENTACION: http://documentacion-emple-depart.tk
 */
package adgui.modelo;

import java.sql.SQLException;

/**
 *
 * @author Félix Marín Ramírez | felixmurcia@gmail.com
 * @version 1.0
 */
public class ConsultaBajaEmple extends AbstractModel {

    private int filasAfectadas;

    /**
     * Constructor de la clase encargado de inicializar la clase de la que
     * hereda.
     *
     * @throws SQLException Lanza la excepción SQLException heredada de la clase
     * padre.
     */
    public ConsultaBajaEmple() throws SQLException, ClassNotFoundException {
        super();
    }

    /**
     * 
     * @return Devuelve el número de filas afectadas en la operación DML.
     */
    public int getFilasAfectadas() {
        return filasAfectadas;
    }

    /**
     * Método utilizdo para dar de baja un empleado.
     * @param EMP_NO Número de empleado
     * @throws SQLException Si se produce un error en el borrado de datos
     * lanzará una excepción.
     */
    public void bajaEmple(final int EMP_NO) throws SQLException, ClassNotFoundException {
        super.conexion();
        super.setConsulta("DELETE FROM emple WHERE  emp_no = " + EMP_NO);
        super.st = super.getConexion().createStatement();        
        this.filasAfectadas = super.st.executeUpdate(super.getConsulta());
        super.cerrarConexion();
        super.cerrarStatements();
    }
}
